package com.sloera.spring.tx;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author sloera
 * @create 2020/4/12
 */
@Service("cashier")
public class CashierImpl implements Cashier {
    @Autowired
    private BookShopSservice bookShopSservice;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void checkout(String username, List<String> isbns) {
        for (String isbn : isbns) {
            bookShopSservice.purchase(username, isbn);
        }
    }
}
